<?php
/*
 * @Author: your name
 * @Date: 2020-05-22 10:40:02
 * @LastEditTime: 2020-05-22 14:07:44
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /v3/application/adminapiv3/service/attackLogManage/cloudSafeLogManage/CloudSafeService.php
 */ 
namespace app\adminapiv3\service\attackLogManage\cloudSafeLogManage;

use app\adminapiv3\service\attackLogManage\AttackLogService;

class CloudSafeService extends AttackLogService
{
    /**
     * @name: 列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 10:42:30
     */
    function list ($input)
    {

        $input['hsot_id']= $this->belongedHost();
        $return = $this->DbList($input);

        return $return;
    }

    /**
     * @name: 数据库列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 10:44:48
     */
    function DbList ($filterData)
    {
        $server = db('CloudSafe');
        !isset($filterData['host_id']) || !empty($filterData['host_id']) ? : $server->whereIn('host_id', $filterData['host_id']);
        !isset($filterData['ctime']) || !is_numeric($filterData['ctime']) ? : $server->where('ctime', $filterData['ctime']);
        !isset($filterData['title']) || empty($filterData['title']) ? : $server->whereLike('title', '%'. $filterData['title'] . '%');
        !isset($filterData['content']) || empty($filterData['content']) ? : $server->whereLike('content', '%'. $filterData['content'] .'%');
        if (isset($filterData['ctime']) && !empty($filterData['ctime']))
        {
            $stime = strtotime($filterData['ctime']);
            $etime = $stime + 86400;
            $server->whereBetween('ctime', [$stime,$etime]);
        }

        $return = $server->paginate(getLimits($page, $limit))->toArray();

        return $return;
    }

    
     /**
     * @name: 删除
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 10:57:44
     */
    function delete ($id_s)
    {
        $host_id_a = $this->belongedHost();
        db('CloudSafe')->whereIn('id', $id_s)->whereIn('host_id', $host_id_a)->delete();
    }

    /**
     * @name: 清空
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 10:57:44
     */
    function clear ()
    {
        $host_id_a = $this->belongedHost();
        db('CloudSafe')->whereIn('host_id', $host_id_a)->delete();
    }
}